//
//  BKVersionCheckNetRequset.m
//  bestkeep
//
//  Created by windCould on 17/1/11.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BKVersionCheckNetRequset.h"

#if ApplicationEnvironmentProduction

NSString * const BKCheckVersionBaseUrl = @"http://api.bestkeep.cn/";
#else

NSString * const BKCheckVersionBaseUrl = @"http://api.test.bestkeep.cn/";

#endif

NSString * const BKCheckVGetVersionUrl = @"http://itunes.apple.com/lookup?id=1035553463";
NSString * const BKCheckVIsForeceUpdateUrl = @"v1/version/ios-p";
NSString * const BKCheckVRemindUpdateUrl = @"updateRemind";

#ifdef DEBUG
#define BKVersionCHeckAPP_VERSION [NSString stringWithFormat:@"%@.%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]
#else
#define BKVersionCHeckAPP_VERSION [NSString stringWithFormat:@"%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]]
#endif

@implementation BKVersionCheckNetRequset

+(void)getVersionInfoWithResultBlock:(void(^)(id obj , NSError * error))resultBlock
{
     [[RequestManager manager]bkDataRequest:RequestMethodPost URLString:BKCheckVGetVersionUrl parameters:nil success:^(id  _Nullable responseObject) {
         
         resultBlock(responseObject,nil);
     } failure:^(id  _Nullable responseObject, NSError * _Nullable error) {
         
         resultBlock(nil,error);
     }];

}

+(void)getIsForceUpdateBKAppVersionOrderWithResultBlock:(void(^)(id obj,NSError * error))resultBlock
{
    NSString * urlStr = [BKCheckVersionBaseUrl stringByAppendingString:BKCheckVIsForeceUpdateUrl];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    [dict setValue:BKVersionCHeckAPP_VERSION forKey:@"version"];
    [[RequestManager manager]bkDataRequest:RequestMethodPost URLString:urlStr parameters:dict success:^(id  _Nullable responseObject) {
        
        resultBlock(responseObject,nil);
    } failure:^(id  _Nullable responseObject, NSError * _Nullable error) {
        
        resultBlock(nil,error);
    }];

}

+(void)getMindUserUpdateBKAppVersionWithResultBlock:(void(^)(id obj,NSError * error))resultBlock
{
    NSString * urlStr = [BKCheckVersionBaseUrl stringByAppendingString:BKCheckVRemindUpdateUrl];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    [dict setValue:BKVersionCHeckAPP_VERSION forKey:@"version"];
    [[RequestManager manager]bkDataRequest:RequestMethodPost URLString:urlStr parameters:dict success:^(id  _Nullable responseObject) {
        
        resultBlock(responseObject,nil);
    } failure:^(id  _Nullable responseObject, NSError * _Nullable error) {
        
        resultBlock(nil,error);
    }];

}


@end
